package com.jie.boot.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import spring.data.jpa.repository.CommonJpaRepository;
import spring.data.jpa.repository.support.JpaSearchSupport;
import spring.data.jpa.tools.DBHelper;

import com.jie.boot.domain.Task;

@Service
public class TaskService {

    @Resource(name = "taskRepository")
    private CommonJpaRepository<Task, Long> taskRepository;

    @Transactional
    public void save(Task entity) {
        taskRepository.save(entity);
    }

    public List<Task> findAll(JpaSearchSupport searchDefinition) {
        return taskRepository.findAll(DBHelper.buildSpecification(searchDefinition, Task.class));
    }
}
